package com.atguigu.guli.order.controller;

import com.atguigu.guli.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

// 动态刷新配置中心的配置
@RefreshScope
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;

    @Value("${order.app.name}")
    private String appName;
//    @Value("${redis.host}")
//    String redisHost;
//    @Value("${redis.port}")
//    Integer redisPort;

    @GetMapping("{userId}/{productId}/{count}")
    public Boolean createOrder(@PathVariable("userId")String userId,
                               @PathVariable("productId")String productId,
                               @PathVariable("count")Integer count){
        System.out.println("配置中心参数appName："+ appName);
//        System.out.println("配置中心redis参数：host = "+ redisHost+" , port = "+ redisPort);
        return orderService.saveOrder(userId,productId,count);
    }
}
